import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import WindiCSS from 'vite-plugin-windicss';

import path from "path";


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue({
    reactivityTransform: true
  }),
  WindiCSS(),
  AutoImport({
    imports: ['vue'],
    resolvers: [
      ElementPlusResolver(),
    ]
  }),
  Components({
    resolvers: [ElementPlusResolver()]
  })
  ],
  base: './',
  outDir: 'dist',
  resolve: {
    alias: {
      "~": path.resolve(__dirname, "src")
    }
  },
  server: {
    port: 3380,
    hmr: true,
    open: true,
    https: false,
    ssr: false,
    proxy: {
      '/api': {
        target: 'http://hnrkdt.com/api',
        // target: 'http://192.168.10.143:8111',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  build: {
    outDir: './dist',
    target: 'modules',
    assetsDir: 'assets',
    assetsInlineLimit: 360000,
  },
  devServer: {
    host: 'localhost',
    port: 8866,
    overlay: false
  }
});
